]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Use the right conversion from cairo to GdkPixbuf
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sat, 16 Feb 2013 02:50:28 +0000 (03:50 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Sat, 16 Feb 2013 03:09:21 +0000 (04:09 +0100)
GdkPixbuf is stored in memory as individual bytes, in strict red-green-blue-alpha
order, while cairo image surfaces are stored as 32bits units whose
order depends on the endianess.
It is probably possible to do something better, taking advantage
of cogl and the GL using the actual component order, but for now
it is easier to use the GDK utility to convert the cairo surface.

https://bugzilla.gnome.org/show_bug.cgi?id=693931

src/shell-screenshot.c

index 924713fdb907b26403b379cfc4cc8a609c1e516b..c354612c5493c0d0124ca00f3f58462528e6c6e9 100644 (file)
@@ -183,22 +183,19 @@ write_screenshot_thread (GSimpleAsyncResult *result,
   else
     {
       GdkPixbuf *pixbuf;
-      pixbuf = gdk_pixbuf_new_from_data (cairo_image_surface_get_data (screenshot_data->image),
-                                         GDK_COLORSPACE_RGB,
-                                         TRUE,
-                                         8,
-                                         cairo_image_surface_get_width (screenshot_data->image),
-                                         cairo_image_surface_get_height (screenshot_data->image),
-                                         cairo_image_surface_get_stride (screenshot_data->image),
-                                         NULL,
-                                         NULL);
+
+      pixbuf = gdk_pixbuf_get_from_surface (screenshot_data->image,
+                                            0, 0,
+                                            cairo_image_surface_get_width (screenshot_data->image),
+                                            cairo_image_surface_get_height (screenshot_data->image));
+
       if (gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, NULL,
                                     "tEXt::Software", "gnome-screenshot", NULL))
         status = CAIRO_STATUS_SUCCESS;
       else
         status = CAIRO_STATUS_WRITE_ERROR;
 
-      g_clear_object (&pixbuf);
+      g_object_unref (pixbuf);
     }